Is it possible to call the main(String[] args) after catching an exception?

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-05-03T13:17:45Z Indexed on 2010/05/03 13:28 UTC
Read the original article Hit count: 222

Filed under:
|
|

I'm working on a Serpinski triangle program that asks the user for the levels of triangles to draw. In the interests of idiot-proofing my program, I put this in:

Scanner input= new Scanner(System.in);
System.out.println(msg);
try {
    level= input.nextInt();
} catch (Exception e) {
    System.out.print(warning);
    //restart main method
}

Is it possible, if the user punches in a letter or symbol, to restart the main method after the exception has been caught?

© Stack Overflow or respective owner

Related posts about java

Related posts about homework